using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using net_work.Data.Entity.Sys;

namespace net_work.Config.DataBaseConfig.Sys;

/// <summary>
/// 学院实体配置类
/// </summary>
public class CollegeEntityTypeConfiguration : IEntityTypeConfiguration<College>
{
    public void Configure(EntityTypeBuilder<College> builder)
    {
        builder.ToTable("sys_colle");

        builder.HasKey(c => c.Id);

        builder.HasIndex(c => c.ColleName).IsUnique();

        // 配置字段名映射
        builder.Property(c => c.Id).HasColumnName("colle_id");
        builder.Property(c => c.ColleName).HasColumnName("colle_name").IsRequired().HasMaxLength(64);
        builder.Property(c => c.ColleEstTime).HasColumnName("colle_est_time").IsRequired().HasColumnType("date");
        builder.Property(c => c.ColleAddr).HasColumnName("colle_addr").HasMaxLength(256);
        builder.Property(c => c.ColleDesc).HasColumnName("colle_desc").HasMaxLength(512);
        builder.Property(c => c.DeanId).HasColumnName("dean_id");

        builder.Property(c => c.CreatedBy).HasColumnName("create_by").IsRequired().HasMaxLength(64);
        builder.Property(c => c.CreatedTime).HasColumnName("create_time").IsRequired();
        builder.Property(c => c.UpdatedBy).HasColumnName("update_by").IsRequired().HasMaxLength(64);
        builder.Property(c => c.UpdatedTime).HasColumnName("update_time").IsRequired();
        builder.Property(c => c.Remark).HasColumnName("remark").HasMaxLength(256);
        builder.Property(c => c.DelFlag).HasColumnName("del_flag").HasDefaultValue('0');
    }
}